package com.mengxuegu.springboot.controller;

import com.mengxuegu.springboot.entities.Provider;
import com.mengxuegu.springboot.mapper.ProviderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class ProviderController {

    @Autowired
    ProviderMapper providerMapper;


    @GetMapping("/provider/{pid}")
    public Provider getProvider(@PathVariable("pid") Integer pid) {
        Provider provider = providerMapper.getProviderByPid(pid);
        return provider;
    }

    @PostMapping("/provider")
    public Provider addProvider(@RequestBody Provider provider) {
        providerMapper.addProvider(provider);
        return provider;
    }
}
